<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>登录</title>
<link rel="stylesheet" href="/static/css/user/login.css" type="text/css">
</head>
<body>
  <form action="/user/login" method="POST">
    <input type="hidden" name="action" id="action" value="login"/>
  <table class="login_table">
   <tbody>
    <tr>
     <td colspan="2" align="center"> <h1>登录</h1> </td>
    </tr>
    <tr id="tips_row" style="display: none;">
     <td colspan="2" align="center">
      <span id="tips" style="color:red;"></span>
     </td>
    </tr>
    <tr>
     <th width="30%"> 账号 </th>
     <td> <input type="text" name="account" id="account"  class="inputs" style="width: 80%"/> </td>
    </tr>
    <tr>
     <th width="30%"> 密码 </th>
     <td> <input type="password" name="password" id="password" class="inputs" style="width: 80%" /> </td>
    </tr>

    <tr>
     <td colspan="2" align="center">
      <input type="button" class="btns" onclick="loginCheck();" value="登录" /> </td>
    </tr>
   </tbody>
  </table>
</form>
<script src="/static/js/jquery.min.js"></script>
<script type="text/javascript">
    function loginCheck()
    {
          var loginForm=$("#login_form");
          var account=$("#account").val();
          var password=$("#password").val();
          var action=$("#action").val();
          $.ajax({
              url:"/user/login",
              async:false,
              data:{account:account,password:password,action:action},
              type:"post",
              dataType:"json",
              timeout:5000,
              success:function(json){
                if(json.code==1){
                   $('#tips_row').fadeIn();
                   $("#tips").text(json.msg);
                   setTimeout(function(){
                      $('#tips_row').fadeOut();
                      location.href="/user";
                   },(1000));

                }else {
                   $('#tips_row').fadeIn();
                   $("#tips").text(json.msg);
                   setTimeout(function(){
                    $('#tips_row').fadeOut();
                   },(2000));
                }
              },
              error:function(xhr, status){
                  $('#tips_row').fadeIn();
                  $("#tips").text("请求出错:"+xhr.responseText);

              }
            });
    }
</script>
</body>
</html>